function New-AzureDataFactoryV2 {
    Param(
        [Parameter(Mandatory = $true)][string][ValidateScript({ !([string]::IsNullOrWhiteSpace($_)) })]$ADFv2Name,
        [Parameter(Mandatory = $true)][string][ValidateScript({ !([string]::IsNullOrWhiteSpace($_)) })]$ResourceGroupName,
        [Parameter(Mandatory = $true)][string][ValidateScript({ !([string]::IsNullOrWhiteSpace($_)) })]$AzureLocation
    )

    # Get existing Azure Data Factories v2.
    $existingADFs = (Get-AzDataFactoryV2).DataFactoryName

    # Check for naming conflicts and rename if necessary.
    if ($ADFv2Name -iin $existingADFs) {
        Write-Warning 'The Azure Data Factory name you chose is already in use!'
        $ADFv2Name = Get-NewAzureDataFactoryName -Blocklist $existingADFs
    }

    # Create an Azure Data Factory v2 resource.
    do {

        # Create Azure Data Factory v2.
        try {
            $dataFactory = $null
            $dataFactory = Set-AzDataFactoryV2 -ResourceGroupName $ResourceGroupName -Name $ADFv2Name -Location $AzureLocation
        }
        catch {

            # Necessary to get around duplicate names on a global scale.
            if ($_.Exception.Message.Contains('DataFactoryNameInUse')) {
                
                # Display warning. 
                Write-Warning 'The Azure Data Factory name you chose is already in use somewhere else!'

                # Put the name on the blacklist.
                $existingADFs += $ADFv2Name

                # Find another name.
                $ADFv2Name = Get-NewAzureDataFactoryName -Blocklist $existingADFs
                
            } else {
                throw $_
            }
        }
    } while (!$dataFactory)

    # Pass down the ADFv2 name in case it was changed.
    return $dataFactory.DataFactoryName
}